import request from '@/utils/request';
import axios from 'axios'
import { converErrorCodeToMsg } from '../utils/utils';

export async function query({...resetParams}) {
  return request(`/pressure_sensors`,{
    method:'GET',
    params:{
      ...resetParams
    }
  });
}

export async function queryWater({...resetParams}) {
  return request(`/waterworks_device_latest_data`,{
    method:'GET',
  });
}

export async function queryWorkstations1({...resetParams}) {
  return request(`/all_workstations`,{
    method:'GET',
    params:{
      template:1
    }
  });
}

export async function queryPipe() {
  return axios(`http://test.zhsgy.top:7405/geoserver/tulufan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tulufan%3Anewpipeline&outputFormat=application%2Fjson`, {
    method:'GET',
  })
    .then(response => {
      console.log('response',response)
      return response
    })
    .catch((error) => {
      console.log('error',error);
      return error;
    });
}
export async function queryDesignPipe() {
  return axios(`http://test.zhsgy.top:7405/geoserver/tulufan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tulufan%3Apipeline&outputFormat=application%2Fjson`, {
    method:'GET',
  })
    .then(response => {
      console.log('response',response)
      return response
    })
    .catch((error) => {
      console.log('error',error);
      return error;
    });
}

export async function queryHolecover() {
  return axios(`http://test.zhsgy.top:7405/geoserver/tulufan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tulufan%3Amanholecover&outputFormat=application%2Fjson`, {
    method:'GET',
  })
    .then(response => {
      console.log('response',response)
      return response
    })
    .catch((error) => {
      console.log('error',error);
      return error;
    });
}

export async function queryReducevalve() {
  return axios(`http://test.zhsgy.top:7405/geoserver/tulufan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tulufan%3Areducevalve&outputFormat=application%2Fjson`, {
    method:'GET',
  })
    .then(response => {
      console.log('response',response)
      return response
    })
    .catch((error) => {
      console.log('error',error);
      return error;
    });
}

export async function queryAppendageCharac(payload) {
  return axios(`http://test.zhsgy.top:7405/geoserver/tulufan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tulufan%3Apoints%3A${payload.url}&outputFormat=application%2Fjson`, {
    method:'GET',
  })
    .then(response => {
      return response
    })
    .catch((error) => {
      console.log('error',error);
      return error;
    });
}
